﻿@model LeadMaster.Models.LeadsReplacement

@{
    ViewBag.Title = "Create";
}

<div class="spacer"></div>

@using (Html.BeginForm("Create", "LeadsReplacement", FormMethod.Post, new { enctype = "multipart/form-data", id = "formLeadsReplacement" }))
{
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Create Leads Replacement</legend>
        <div class="editor-label">
            @Html.LabelFor(model => model.Title)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Title)
            @Html.ValidationMessageFor(model => model.Title)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.Description, new { @class="notes"})
            @Html.ValidationMessageFor(model => model.Description)
        </div>
        <div class="spacer"></div>
        <div class="editor-label">
            @Html.LabelFor(model => model.DocType)
        </div>
        <div class="editor-field">
            @Html.RadioButtonFor(model => model.DocType, 'T') Text
            @Html.RadioButtonFor(model => model.DocType, 'P') PDF
            @Html.RadioButtonFor(model => model.DocType, 'W') Word
            @Html.ValidationMessageFor(model => model.DocType)
        </div>
        <div class="spacer"></div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Version)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Version)
            @Html.ValidationMessageFor(model => model.Version)
        </div>
        <div class="spacer"></div>
        <div class="editor-label">
            <label for="file">Filename:</label>
        </div>
        <div class="editor-field">
            <input type="file" name="file" id="file" />
        </div>
        <div class="spacer"></div>
        <p>
            <input type="submit" value="Create" />
        </p>
        @Html.HiddenFor(model => model.Filename)
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

<script type="text/javascript">
    $(document).ready(function () {

        $('#formLeadsReplacement').submit(function () {
            var fileName = $('#file').val();
            var soleFileName = fileName.substr(fileName.lastIndexOf("\\") + 1);
            if (soleFileName.length == 0) {
                alert("Please select a document filename");
                return false;
            }
            $('#Filename').val(soleFileName);
            return true;
        });
    });
</script>
